
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <include file="./Public/Admin/header.html" />
    <script type="text/javascript" src="__PUBLIC__js/jquery_wookmark_min.js?2013-10-15-2"></script>
    <script type="text/javascript" src="__PUBLIC__js/masonry.pkgd.min.js?2013-10-15-2"></script>
    <script type="text/javascript" src="__PUBLIC__js/jquery_imagesloaded.js?2013-10-15-2"></script>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__css/emotion.css?2013-10-15-2" media="all" />
    <script type="text/javascript" src="__PUBLIC__js/jquery.pagination.js?2013-10-15-2"></script>
    <script type="text/javascript" src="__PUBLIC__js/emotion.js?2013-10-15-2"></script>
    <script type="text/javascript" src="__PUBLIC__js/resource.js?2013-10-15-2"></script>
    <style type="text/css">
        #tiles {
            list-style-type: none;
            width: 60%;
        }
        ul li{list-style: none;}
        .tab_navs{border-bottom: 1px solid #e7e7eb;line-height: 30px;height: 30px;margin-left: 0px;margin-top: 10px;}
        .tab_nav{float: left;font-size: 15px;width: 15%;text-align: center;}
        .tab_nav a{color: #999;}
        .tab_panel{min-height: 310px;background-color: #fff;}
        .edit_area{height: 310px;display: none;}
        .selected{display: block;}
        #tiles .item_news { width: 350px; margin: 10px; }
        .qf{background-color: #44b549;height: 30px;
            line-height: 30px;
            vertical-align: middle;
            text-align: center;
            border-color: #44b549;
            color: #fff;width: 104px;border-radius: 5px;margin-top: 40px;}
        .qf input{background-color: transparent;
            border: 0;outline: 0;overflow: visible;padding: 0 22px;height: 100%;color: #fff;font-size: 15px;}
        .bubbleTips.warn {color: #e15f63;}
        .bubble_left {margin-left: .5em;}
        .bubbleTips {display: inline-block;vertical-align: middle;position: relative;}
        .bubbleTips_inner {padding: 4.5px 12px;border: 1px solid #e7e7eb;line-height: 21px;background-color: #fff;
            word-wrap: break-word;
            word-break: break-all;
        }
        #loading {width:100%;height:100%;display:none;position:fixed;top:0px;left:0px;background:url('__PUBLIC__images/load.gif') no-repeat center; background-size:2%;background-color:rgba(0, 0, 0, 0.75);z-index:10000000;}
    </style>
    <script type="text/javascript">
        var msgtype='';//类型
        var contentid='';//图文素材ID
        $(function(){
            msgtype='text';
            $(".tab_navs li").click(function(){
                $(".tab_nav a").css("color",'#999');
                $(this).children().css("color","#222");
                var num=$(this).index();
                $(".emotion_editor").children().hide();
                $(".emotion_editor").children().eq(num).show();
                $("#txt_content").val("");
                $("#thumb_img").attr("src","");
                $("#thumb").val("");
                msgtype=$(this).attr("data-type");
                //获取内容类型
                switch(msgtype){
                    case '1':
                        msgtype='text';
                        break;
                    case '2':
                        msgtype='image';
                        break;
                    case '3':
                        msgtype='mpnews';
                        break;
                }
            });
            //群发
            $("#qfsend").click(function(){
                var is_choose=false;
                var openids = new Array();
                //全选框被选中的情况
                if($("input[name='checkall']").prop("checked")) {
                    openids[0]='0';
                    is_choose=true;
                } else {
                    var check = $("input[name='check']:checked");
                    if(check.length>0){
                        is_choose=true;
                    }
                    check.each(function(i){
                        openids[i] = $(this).val();
                    });
                }
                if(!is_choose){
                    alert('请选择群发用户');
                    return false;
                }
                var sendtype=$("#sendtype").val();
                if(sendtype==""){
                    alert("请选择群发方式");
                    return;
                }
                var url='';
                if(sendtype=='msg_send'){
                    url="{:U('Admin/Wechat/msg_send')}";
                }
                if(sendtype=='custom_send'){
                    url="{:U('Admin/Wechat/custom_send')}";
                }
                var keyword=$.trim($("#keyword").val());
                var pro=$("#pro").val();
                var pro_name=$("#pro_name").val();
                if(msgtype=='text'){
                    var content= $("#txt_content").val();
                    if(content==''){
                        alert("请填写内容");
                        return;
                    }
                    $.post(url,{msgtype:msgtype,content:content,openids:openids,keyword:keyword,pro:pro,pro_name:pro_name},function(data){
                        //已经获取到
                        if(data.errno==1){
                            alert("发送成功！");
                        }else{
                            alert("发送失败，请重新发送！");
                        }
                        $("#loading").hide();
                    },'json');
                }else if(msgtype=='image'){
                    if($("#thumb").val()==''){
                        alert("请上传图片");
                        return;
                    }
                    $.post(url,{msgtype:msgtype,upimg:$("#thumb").val(),openids:openids,keyword:keyword,pro:pro,pro_name:pro_name},function(data){
                        //已经获取到
                        if(data.errno==1){
                            alert("发送成功！");
                        }else{
                            alert("发送失败，请重新发送！");
                        }
                        $("#loading").hide();
                    },'json');
                }else if(msgtype='mpnews'){
                    if(sendtype=="custom_send"){
                        //客户接口群发
                        msgtype="news";
                    }
                    if(contentid==''){
                        alert("请选择素材");
                        return;
                    }
                    $.post(url,{msgtype:msgtype,contentid:contentid,openids:openids,keyword:keyword,pro:pro,pro_name:pro_name},function(data){
                        console.log(data.errno);
                        //已经获取到
                        if(data.errno==1){
                            alert("发送成功！");
                        }else{
                            alert("发送失败，请重新发送！");
                        }

                        $("#loading").hide();
                    },'json');
                }
                $("#loading").show();
            });
            //选择项目
            $("#pro").change(function(){
                var pro=$("#pro").val();
                if(pro=='0'){
                    $("#pro_name").html('');
                    return;
                }
                $.post("{:U('Admin/Template/get_proname')}",{pro_name:pro},function(data){
                    var html='<option value="0">--请选择项目期数--</option>';
                    $.each(data.msg,function(i,n){
                        html+='<option value="'+ n.pro_num+'">'+ n.pro_num+'</option>';
                    });
                    $("#pro_name").html('');
                    $("#pro_name").append(html);
                },'json');
            });
        });
    </script>
</head>
<body>
<div id="main">
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div class="box">
<div class="box-title">
    <div class="span4">
        <h3><i class="icon-table"></i>群发功能</h3>
    </div>
</div>
<div class="box-content">
<span style="font-size:15px;"> 群发用户：</span>
<div class="row-fluid" style="height: 300px;overflow-y: auto;border:1px solid #ccc;margin-bottom:20px;">
    <div class="box-content">
        <div class="row-fluid">
            <div class="span12">
                <form action="{:U('Admin/Wechat/owners_sendmsg')}" method="get" class="form-horizontal" style="margin: 0px;">
                    <div class="span12">
                        <div class="span5">
                            关键字：<input type="text" id="keyword" name="keyword" value="<?php echo isset($keyword)?$keyword:'';?>" placeholder="请输入姓名、电话或身份证查询" />
                        </div>
                    </div>
                    <div class="span12" style="margin-left: 0;margin-top: 10px;">
                        <div class="span5">
                            项目名称：
                            <select name="pro" id="pro">
                                <?php if(!empty($pro)){?>
                                <option value="<?php echo $pro;?>"><?php echo $pro;?></option>
                                <?php }else{?>
                                <option value="" selected="selected">--请选择项目--</option>
                                <?php }?>
                                <foreach name="pros" item="item">
                                    <option value="{$item.pro_name}">{$item.pro_name}</option>
                                </foreach>
                            </select>
                        </div>
                    </div>
                    <div class="span12" style="margin-left: 0;margin-top: 10px;margin-bottom: 10px;">
                        <div class="span5">
                            项目期数：
                            <select name="pro_name" id="pro_name">
                                <?php if(!empty($pro_name)){?>
                                <option value="<?php echo $pro_name;?>"><?php echo $pro_name;?></option>
                                <?php }else{?>
                                <option value="">--请选择项目期数--</option>
                                <?php }?>
                            </select>
                            <button class="btn" id="btn_search">查询</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="row-fluid dataTables_wrapper" >
            <table id="listTable" class="table table-bordered table-hover  dataTable">
                <thead>
                <tr>
                    <th class='with-checkbox'><input type="checkbox" class="check_all" /></th>
                    <th>姓名</th>
                    <th>电话</th>
                    <th>身份证</th>
                    <th>房源信息</th>
                </tr>
                </thead>
                <tbody>
                <foreach name="users" item="item">
                    <tr>
                        <td class="with-checkbox">
                            <input type="checkbox" name="check" value="{$item.openid}">
                        </td>
                        <td>{$item.uname}</td>
                        <td>{$item.phone}</td>
                        <td>{$item.idcard}</td>
                        <td>{$item.buname}{$item.bldfullname}{$item.room}</td>
                    </tr>
                </foreach>
                <if condition="$total==0">
                    <tr><td align="center" colspan="10">暂无记录</td></tr>
                </if>

                </tbody>
            </table>
            <div class="row-fluid">
                <div class="span4">
                    <div class="dataTables_info">
                        <if condition="$total gt 0">
                            共{$total}条记录，当前第{$nowPage}/{$totalPages}页
                        </if>
                    </div>
                </div>
                <div class="span8">
                    <div class="dataTables_paginate paging_full_numbers">
                                        <span>
                                            {$page}
                                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row-fluid">
    <div class="span8 control-group">
        <span style="font-size:15px;"> 群发方式：</span>
        <select id="sendtype">
            <option value="">--请选择群发方式--</option>
            <option value="msg_send">高级群发</option>
            <option value="custom_send">客服群发</option>
        </select>
    </div>
</div>
<div class="row-fluid" id="user_group" style="display: none;">
    <div class="span8 control-group">
        <span style="font-size:15px;">分组选择：</span>
        <select id="group">
            <option value="">--请选择分组--</option>
            <foreach name="groups" item="item">
                <option value="{$item.id}">{$item.groupname}</option>
            </foreach>
        </select>
    </div>
</div>
<div class="row-fluid dataTables_wrapper">
<div  id="newslist">
<div id="tiles" style="border: 1px solid #e7e7eb;">
<div class="msg_tab">
<ul class="tab_navs" >
    <li class="tab_nav tab_text width5 selected" data-type="1" data-tab=".js_textArea" data-tooltip="文字">
        <a href="javascript:void(0);" style="color:#222;">文字</a>
    </li>
    <li class="tab_nav tab_img width5"  onClick="upImage()" data-type="2" data-tab=".js_imgArea" data-tooltip="图片">
        <a href="javascript:void(0);">图片</a>
    </li>
    <li class="tab_nav tab_appmsg width5 no_extra" data-type="3" onClick="selcontents()" class="btn btn-mini" data-tab=".js_appmsgArea" data-tooltip="图文消息">
        <a href="javascript:void(0);">图文消息</a>
    </li>
</ul>
<div class="tab_panel">
<div class="tab_content" style="display: block;">
<div class="js_textArea inner no_extra">
<div class="emotion_editor">
<div class="edit_area js_editorArea selected" style="overflow-y: auto; overflow-x: hidden;">
<!--文本-->
<div class="control-group" id="textreply">
<div class="controls">
<div class="txtArea">
<div class="functionBar">
<div class="opt">
    <a class="icon18C iconEmotion block" href="javascript:;">表情</a>
</div>
<div class="tip"></div>
<div class="emotions">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
    <td>
        <div class="eItem" style="background-position: 0px 0;"
             data-title="微笑"
             data-gifurl="__PUBLIC__img/face/0.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -24px 0;"
             data-title="撇嘴"
             data-gifurl="__PUBLIC__img/face/1.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -48px 0;"
             data-title="色"
             data-gifurl="__PUBLIC__img/face/2.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -72px 0;"
             data-title="发呆"
             data-gifurl="__PUBLIC__img/face/3.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -96px 0;"
             data-title="得意"
             data-gifurl="__PUBLIC__img/face/4.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -120px 0;"
             data-title="流泪"
             data-gifurl="__PUBLIC__img/face/5.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -144px 0;"
             data-title="害羞"
             data-gifurl="__PUBLIC__img/face/6.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -168px 0;"
             data-title="闭嘴"
             data-gifurl="__PUBLIC__img/face/7.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -192px 0;"
             data-title="睡"
             data-gifurl="__PUBLIC__img/face/8.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -216px 0;"
             data-title="大哭"
             data-gifurl="__PUBLIC__img/face/9.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -240px 0;"
             data-title="尴尬"
             data-gifurl="__PUBLIC__img/face/10.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -264px 0;"
             data-title="发怒"
             data-gifurl="__PUBLIC__img/face/11.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -288px 0;"
             data-title="调皮"
             data-gifurl="__PUBLIC__img/face/12.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -312px 0;"
             data-title="呲牙"
             data-gifurl="__PUBLIC__img/face/13.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -336px 0;"
             data-title="惊讶"
             data-gifurl="__PUBLIC__img/face/14.gif">
        </div>
    </td>
</tr>
<tr>
    <td>
        <div class="eItem" style="background-position: -360px 0;"
             data-title="难过"
             data-gifurl="__PUBLIC__img/face/15.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -384px 0;"
             data-title="酷"
             data-gifurl="__PUBLIC__img/face/16.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -408px 0;"
             data-title="冷汗"
             data-gifurl="__PUBLIC__img/face/17.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -432px 0;"
             data-title="抓狂"
             data-gifurl="__PUBLIC__img/face/18.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -456px 0;"
             data-title="吐"
             data-gifurl="__PUBLIC__img/face/19.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -480px 0;"
             data-title="偷笑"
             data-gifurl="__PUBLIC__img/face/20.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -504px 0;"
             data-title="可爱"
             data-gifurl="__PUBLIC__img/face/21.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -528px 0;"
             data-title="白眼"
             data-gifurl="__PUBLIC__img/face/22.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -552px 0;"
             data-title="傲慢"
             data-gifurl="__PUBLIC__img/face/23.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -576px 0;"
             data-title="饥饿"
             data-gifurl="__PUBLIC__img/face/24.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -600px 0;"
             data-title="困"
             data-gifurl="__PUBLIC__img/face/25.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -624px 0;"
             data-title="惊恐"
             data-gifurl="__PUBLIC__img/face/26.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -648px 0;"
             data-title="流汗"
             data-gifurl="__PUBLIC__img/face/27.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -672px 0;"
             data-title="憨笑"
             data-gifurl="__PUBLIC__img/face/28.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -696px 0;"
             data-title="大兵"
             data-gifurl="__PUBLIC__img/face/29.gif">
        </div>
    </td>
</tr>
<tr>
    <td>
        <div class="eItem" style="background-position: -720px 0;"
             data-title="奋斗"
             data-gifurl="__PUBLIC__img/face/30.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -744px 0;"
             data-title="咒骂"
             data-gifurl="__PUBLIC__img/face/31.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -768px 0;"
             data-title="疑问"
             data-gifurl="__PUBLIC__img/face/32.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -792px 0;"
             data-title="嘘"
             data-gifurl="__PUBLIC__img/face/33.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -816px 0;"
             data-title="晕"
             data-gifurl="__PUBLIC__img/face/34.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -840px 0;"
             data-title="折磨"
             data-gifurl="__PUBLIC__img/face/35.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -864px 0;"
             data-title="衰"
             data-gifurl="__PUBLIC__img/face/36.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -888px 0;"
             data-title="骷髅"
             data-gifurl="__PUBLIC__img/face/37.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -912px 0;"
             data-title="敲打"
             data-gifurl="__PUBLIC__img/face/38.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -936px 0;"
             data-title="再见"
             data-gifurl="__PUBLIC__img/face/39.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -960px 0;"
             data-title="擦汗"
             data-gifurl="__PUBLIC__img/face/40.gif">
        </div>
    </td>
    <td>
        <div class="eItem" style="background-position: -984px 0;"
             data-title="抠鼻"
             data-gifurl="__PUBLIC__img/face/41.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1008px 0;" data-title="鼓掌"
             data-gifurl="__PUBLIC__img/face/42.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1032px 0;" data-title="糗大了"
             data-gifurl="__PUBLIC__img/face/43.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1056px 0;" data-title="坏笑"
             data-gifurl="__PUBLIC__img/face/44.gif">
        </div>
    </td>
</tr>
<tr>
    <td>
        <div class="eItem"
             style="background-position: -1080px 0;" data-title="左哼哼"
             data-gifurl="__PUBLIC__img/face/45.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1104px 0;" data-title="右哼哼"
             data-gifurl="__PUBLIC__img/face/46.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1128px 0;" data-title="哈欠"
             data-gifurl="__PUBLIC__img/face/47.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1152px 0;" data-title="鄙视"
             data-gifurl="__PUBLIC__img/face/48.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1176px 0;" data-title="委屈"
             data-gifurl="__PUBLIC__img/face/49.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1200px 0;" data-title="快哭了"
             data-gifurl="__PUBLIC__img/face/50.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1224px 0;" data-title="阴险"
             data-gifurl="__PUBLIC__img/face/51.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1248px 0;" data-title="亲亲"
             data-gifurl="__PUBLIC__img/face/52.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1272px 0;" data-title="吓"
             data-gifurl="__PUBLIC__img/face/53.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1296px 0;" data-title="可怜"
             data-gifurl="__PUBLIC__img/face/54.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1320px 0;" data-title="菜刀"
             data-gifurl="__PUBLIC__img/face/55.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1344px 0;" data-title="西瓜"
             data-gifurl="__PUBLIC__img/face/56.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1368px 0;" data-title="啤酒"
             data-gifurl="__PUBLIC__img/face/57.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1392px 0;" data-title="篮球"
             data-gifurl="__PUBLIC__img/face/58.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1416px 0;" data-title="乒乓"
             data-gifurl="__PUBLIC__img/face/59.gif">
        </div>
    </td>
</tr>
<tr>
    <td>
        <div class="eItem"
             style="background-position: -1440px 0;" data-title="咖啡"
             data-gifurl="__PUBLIC__img/face/60.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1464px 0;" data-title="饭"
             data-gifurl="__PUBLIC__img/face/61.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1488px 0;" data-title="猪头"
             data-gifurl="__PUBLIC__img/face/62.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1512px 0;" data-title="玫瑰"
             data-gifurl="__PUBLIC__img/face/63.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1536px 0;" data-title="凋谢"
             data-gifurl="__PUBLIC__img/face/64.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1560px 0;" data-title="示爱"
             data-gifurl="__PUBLIC__img/face/65.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1584px 0;" data-title="爱心"
             data-gifurl="__PUBLIC__img/face/66.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1608px 0;" data-title="心碎"
             data-gifurl="__PUBLIC__img/face/67.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1632px 0;" data-title="蛋糕"
             data-gifurl="__PUBLIC__img/face/68.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1656px 0;" data-title="闪电"
             data-gifurl="__PUBLIC__img/face/69.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1680px 0;" data-title="炸弹"
             data-gifurl="__PUBLIC__img/face/70.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1704px 0;" data-title="刀"
             data-gifurl="__PUBLIC__img/face/71.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1728px 0;" data-title="足球"
             data-gifurl="__PUBLIC__img/face/72.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1752px 0;" data-title="瓢虫"
             data-gifurl="__PUBLIC__img/face/73.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1776px 0;" data-title="便便"
             data-gifurl="__PUBLIC__img/face/74.gif">
        </div>
    </td>
</tr>
<tr>
    <td>
        <div class="eItem"
             style="background-position: -1800px 0;" data-title="月亮"
             data-gifurl="__PUBLIC__img/face/75.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1824px 0;" data-title="太阳"
             data-gifurl="__PUBLIC__img/face/76.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1848px 0;" data-title="礼物"
             data-gifurl="__PUBLIC__img/face/77.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1872px 0;" data-title="拥抱"
             data-gifurl="__PUBLIC__img/face/78.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1896px 0;" data-title="强"
             data-gifurl="__PUBLIC__img/face/79.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1920px 0;" data-title="弱"
             data-gifurl="__PUBLIC__img/face/80.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1944px 0;" data-title="握手"
             data-gifurl="__PUBLIC__img/face/81.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1968px 0;" data-title="胜利"
             data-gifurl="__PUBLIC__img/face/82.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -1992px 0;" data-title="抱拳"
             data-gifurl="__PUBLIC__img/face/83.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2016px 0;" data-title="勾引"
             data-gifurl="__PUBLIC__img/face/84.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2040px 0;" data-title="拳头"
             data-gifurl="__PUBLIC__img/face/85.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2064px 0;" data-title="差劲"
             data-gifurl="__PUBLIC__img/face/86.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2088px 0;" data-title="爱你"
             data-gifurl="__PUBLIC__img/face/87.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2112px 0;" data-title="NO"
             data-gifurl="__PUBLIC__img/face/88.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2136px 0;" data-title="OK"
             data-gifurl="__PUBLIC__img/face/89.gif">
        </div>
    </td>
</tr>
<tr>
    <td>
        <div class="eItem"
             style="background-position: -2160px 0;" data-title="爱情"
             data-gifurl="__PUBLIC__img/face/90.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2184px 0;" data-title="飞吻"
             data-gifurl="__PUBLIC__img/face/91.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2208px 0;" data-title="跳跳"
             data-gifurl="__PUBLIC__img/face/92.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2232px 0;" data-title="发抖"
             data-gifurl="__PUBLIC__img/face/93.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2256px 0;" data-title="怄火"
             data-gifurl="__PUBLIC__img/face/94.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2280px 0;" data-title="转圈"
             data-gifurl="__PUBLIC__img/face/95.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2304px 0;" data-title="磕头"
             data-gifurl="__PUBLIC__img/face/96.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2328px 0;" data-title="回头"
             data-gifurl="__PUBLIC__img/face/97.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2352px 0;" data-title="跳绳"
             data-gifurl="__PUBLIC__img/face/98.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2376px 0;" data-title="挥手"
             data-gifurl="__PUBLIC__img/face/99.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2400px 0;" data-title="激动"
             data-gifurl="__PUBLIC__img/face/100.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2424px 0;" data-title="街舞"
             data-gifurl="__PUBLIC__img/face/101.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2448px 0;" data-title="献吻"
             data-gifurl="__PUBLIC__img/face/102.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2472px 0;" data-title="右太极"
             data-gifurl="__PUBLIC__img/face/103.gif">
        </div>
    </td>
    <td>
        <div class="eItem"
             style="background-position: -2496px 0;" data-title="左太极"
             data-gifurl="__PUBLIC__img/face/104.gif">
        </div>
    </td>
</tr>
</tbody>
</table>
<div class="emotionsGif"></div>
</div>
<div class="clr"></div>
</div>
<div class="editArea" >
    <textarea name="txt_content" id="txt_content" style="display: none;" title="first tooltip"></textarea>
    <div contenteditable="true" style="overflow-y: auto; overflow-x: hidden;height:190px;"></div>
</div>
</div>

<span class="maroon">*</span><span class="help-inline">必填, 用户添加您的时候自动回复语；超链接添加形式，如：&lt;a href="http://www.baidu.com"&gt;百度&lt;/a&gt;</span>
</div>
</div><!--文本-->
</div>
<div class="edit_area js_editorArea" contenteditable="true" style="overflow-y: auto; overflow-x: hidden;">
    <img id="thumb_img" src="" style="max-height:80px;" />
    <input type="hidden" id="thumb" value="" />
</div>
<div class="edit_area js_editorArea" id="tuwen" contenteditable="true" style="overflow-y: auto; overflow-x: hidden;">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="qf">
    <input type="button" value="群发" id="qfsend" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>



<!--设置-->
<style type="text/css">
    #myModal {width: 900px;margin: 0px 0 0 -450px;}
    .con-masonry {list-style-type: none;margin: 0 auto;}
    .con-masonry .item_news {width: 350px;margin: 5px;}
</style>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
    <div class="modal-header">
        <button class="close" type="button" data-dismiss="modal">×</button> <h3>设置内容</h3>
    </div>
    <div class="modal-body">
        <iframe id='iframe01' style="zoom: 0.6;overflow-x:hidden; display:none;" src="" frameBorder="0" marginheight="0" marginwidth="0" width="99.8%" height="600"></iframe>
        <ul class="nav nav-tabs" id="myTab">
            <li><a href="#replynews" data-toggle="tab" data-type="news">图文素材</a></li>
        </ul>
        <div class="tab-content dataTables_wrapper">
            <div class="tab-pane active" id="replynews">
                <div class="con-masonry"  >
                </div>
            </div>
            <div  class="dataTables_paginate paging_full_numbers " id="pagination"></div>
        </div>
    </div>
    <div class="modal-footer hide">
        <button class="btn btn-primary" data-dismiss="modal">确定</button>
    </div>
</div>
<script type="text/javascript">
    Emotion.url='__PUBLIC__img/face/';
    $(function () {
        $('.des').each(function(){
            var c=$(this).html();
            c=Emotion.replaceEmoji(c);
            c=c.replace(/&lt;/gi, "<").replace(/&gt;/gi, ">");
            $(this).html(c);
        })
    });
</script>

<script type="text/javascript">
    function selcontents(){
        $('#myModal').modal('show');
    }
    function getcontent(){
        $('.con-masonry').masonry({
            itemSelector : '.item_news',
            columnWidth : 390,//一列的宽度 Integer
            isFitWidth: true,// 适应宽度
            gutterWidth :10,//列的间隙
            isResizableL:true, // 是否可调整大小
            transitionDuration:0,//过渡时间
            isRTL:false//使用从右到左的布局
        });
    }
</script>
<script type="text/javascript">
    var type='news';
    var isinitpage=true;
    $(function () {
        $('a[data-toggle="tab"]').on('shown', function (e) {
            type=$(this).attr('data-type');
            get_contents(type,0);
            isinitpage=true;
            $('#pagination').show();
        })
        $('#myModal').on('shown', function () {
            get_contents(type,0);
            $('#pagination').show();
        })
    });
    //加载数据
    function get_contents(type,page){
        page=page+1;
        var opts={type:type,page:page};
        $.get("{:U('Admin/Wechat/selcontent')}?t="+new Date().getTime(),opts,function(data){
            if(isinitpage){
                initPagination(data.totlecount);
                isinitpage=false;
            }
            //载入数据
            $('#replynews .con-masonry').empty();
            $('#replynews .con-masonry').masonry('reload');
            if(data.totlecount==0){
                $('#replynews .con-masonry').append('没有图文素材');
            }
            $.each(data.list,function(index,item){
                var str='';
                var conitem=eval("("+item.content+")");//内容转换为json对象
                if(conitem.length==1){
                    //单图文
                    str+='<div class="item_news">'
                    +'<div class="imgEdit" id="imgEdit">'
                    +'<div  id="item_0">'
                    +'<div class="caption div_caption" >'+conitem[0].detailtitle+' </div>'
                    +'<div class="time">'+item.addtime+'</div>'
                    +'<div class="img">'
                    +'<div class="coverImg">'
                    +'<img  src="'+conitem[0].detaillogo+'" />'
                    +'<input value="'+conitem[0].mediaid+'" type="hidden"/>'
                    +'<div class="des">'+conitem[0].detailintro+'</div>'
                    +'</div></div>'
                    +'</div>'
                    +'<div class="clearfix" style="margin-top:10px;">'
                    +'<a class="btn btn-primary selcontent" data-cid="'+item.contentid+'" style="width:300px" title="选择此素材"><i class="icon-ok"></i></a>'
                    +' </div>'
                    +'</div></div>';
                }else{
                    //多图文
                    str+='<div class="item_news">'
                    +'<div class="imgsEdit" id="imgsEdit">'
                    +'<div class="time">'+item.addtime+'</div>'
                    +'<div class="img" id="item_0">'
                    +'<div class="coverImg"><img src="'+conitem[0].detaillogo+'"/></div>'
                    +'<input  value="'+conitem[0].mediaid+'" type="hidden"/>'
                    +'<div class="caption" style=" ">'
                    +'<span  class="div_caption" >'+conitem[0].detailtitle+' </span>'
                    +'</div>'
                    +'</div>'
                    +'<ul class="unstyled">';
                    for(var i=1;i<conitem.length;i++){
                        str+='<li class="item">'
                        +'<div class="caption div_caption">'+conitem[i].detailtitle+' </div>'
                        +'<div class="itemImg coverImg"><img src="'+conitem[i].detaillogo+'"/></div>'
                        +'<input  value="'+conitem[i].mediaid+'" type="hidden"/>'
                        +'<div class="div_content hide"></div>'
                        +'</li>';
                    }
                    str+='</ul> ';
                    str+='<div class="clearfix">'
                    +'<a class="btn btn-primary selcontent"  data-cid="'+item.contentid+'"  style="width:300px" title="选择此素材"><i class="icon-ok"></i></a>'
                    +' </div></div> </div>';
                }
                var $boxes =$(str);
                $('#replynews .con-masonry').append($boxes).masonry('appended', $boxes, true);
            });
            getcontent();
        },'json');
    }

    function initPagination(num_entries){
        //渲染分页
        $('#pagination').pagination(num_entries, {
            current_page : 0,
            items_per_page : 10,
            num_display_entries : 3,
            callback : function(page_id){
                get_contents(type,page_id);
            },
            prev_text : '上一页',
            next_text : '下一页'
        });
    }
    $(function () {
        //选择素材确定
        $('.selcontent').live('click',function(){
            var cid=$(this).attr('data-cid');
            contentid=cid;
            var str="";
            $.post("{:U('Admin/Wechat/getcontent')}",{cid:cid},function(data){
                var str='';
                str+='<div class="item_news">';
                var conitem=eval("("+data.content+")");//内容转换为json对象
                var len=conitem.length;
                if(len==1){
                    str+='<div class="imgEdit " id="imgEdit">'
                    str+= '<div  id="item_0">'
                    +'<div class="caption div_caption" >'+conitem[0].detailtitle+' </div>'
                    +'<div class="time">'+conitem[0].addtime+'</div>'
                    +'<div class="img">'
                    +'<div class="coverImg">'
                    +'<img  src="'+conitem[0].detaillogo+'" />'
                    +'<div class="des">'+conitem[0].detailintro+'</div>'
                    +'</div>'
                    +'</div>'
                    +'</div>'
                    +'</div>';
                }else{
                    str+='<div class="imgsEdit " id="imgsEdit">';

                    str+='<div class="time">'+conitem[0].addtime+'</div>'
                    +'<div class="img" id="item_0">'
                    +'<div class="coverImg"><img src="'+conitem[0].detaillogo+'"/></div>'
                    +'<div class="caption" style=" ">'
                    +'<span  class="div_caption" >'+conitem[0].detailtitle+' </span>'
                    +'</div>'
                    +'</div>'
                    +'<ul class="unstyled">';
                    for(var i=1;i<len;i++){
                        str+='    <li class="item">'
                        +'       <div class="caption div_caption">'+conitem[i].detailtitle+' </div>'
                        +'     <div class="itemImg coverImg"><img src="'+conitem[i].detaillogo+'"/></div>'
                        +'     <input  value="'+conitem[i].mediaid+'" type="hidden"/>'
                        +'     <div class="div_content hide"></div>'
                        +' </li>';
                    }
                    str+='     </ul> ';
                    str+='     </div> ';
                }
                str+='     </div> ';
                $(".item_news").children().remove();
                $('#tuwen').append(str);
                $('#myModal').modal('hide');

            },'json');
        });
    });
</script>
</div>
<div id="loading"></div>
<!--设置-->
</body>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__../ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__../ueditor/ueditor.all.js"></script>

<script type="text/javascript">
    //设置编辑器参数
    var param="type=<?php echo isset($utype)?$utype:''?>&comid=<?php echo isset($comid)?$comid:''?>&aid=<?php echo isset($accountid)?$accountid:''?>";
    var options = {
        initialFrameWidth:"100%",
        initialFrameHeight: 250,
        imageUrl:window.UEDITOR_CONFIG.UEDITOR_HOME_URL+"php/imageUp.php?"+param,
        fileUrl:window.UEDITOR_CONFIG.UEDITOR_HOME_URL+"php/fileUp.php?"+param,
        imageManagerUrl:window.UEDITOR_CONFIG.UEDITOR_HOME_URL + "php/imageManager.php?"+param,
        toolbars:[
            [ 'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist',  '|',

                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                'indent',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
                'link', 'unlink', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                'insertimage', 'emotion',  'horizontal','|','help']
        ]
    };
    //var ue = UE.getEditor('txt_content', options);
</script>
<script type="text/plain" id="upload_ue" style="display: none;"></script>
<script type="text/javascript">

    //重新实例化一个编辑器，防止在上面的editor编辑器中显示上传的图片或者文件
    var _editor = UE.getEditor('upload_ue',options);
    _editor.ready(function () {
        //设置编辑器不可用
        _editor.setDisabled();
        //隐藏编辑器，因为不会用到这个编辑器实例，所以要隐藏
        _editor.hide();
        //侦听图片上传
        _editor.addListener('beforeInsertImage', function (t, arg) {
            //将地址赋值给相应的input,只去第一张图片的路径
            $("#thumb").attr("value", arg[0].src);
            $("#thumb").addClass('hide');
            //图片预览
            $("#thumb_img").attr("src", arg[0].src);
            $("#thumb_img").show();
            // uploadImgCallBack(arg[0].src);
        })

        //侦听文件上传，取上传文件列表中第一个上传的文件的路径
        _editor.addListener('afterUpfile', function (t, arg) {
            $("#file").attr("value", _editor.options.filePath + arg[0].url);
        })
    });
    //弹出图片上传的对话框
    function upImage() {
        var myImage = _editor.getDialog("insertimage");
        myImage.open();
    }
    //弹出文件上传的对话框
    function upFiles() {
        var myFiles = _editor.getDialog("attachment");
        myFiles.open();
    }
</script>

<script type="text/javascript">
    Emotion.url='__PUBLIC__img/face/';
    function godebug(){
        alert(Emotion.url);
    }
    $(function(){
        var $textarea = $(".editArea textarea");
        var $contentDiv = $(".editArea div");
        $(".functionBar .iconEmotion").click(function () {
            //Emotion.saveRange();
            $(".emotions").show();
        });
        $(".emotions").hover(function () {

        }, function () {
            $(".emotions").fadeOut();
        });
        $(".emotions .eItem").mouseenter(function () {
            $(".emotionsGif").html('<img src="' + $(this).attr("data-gifurl") + '">');
        }).click(function () {
            Emotion.insertHTML('<img src="' + $(this).attr("data-gifurl") + '"' + 'alt="mo-' + $(this).attr("data-title") + '"' + "/>");
            $(".emotions").fadeOut();
            $textarea.trigger("contentValueChange");
        });
        $contentDiv.bind("keyup", function () {
            $textarea.trigger("contentValueChange");
            Emotion.saveRange();
        }).bind("keydown", function (e) {
            switch (e.keyCode) {
                case 8:
                    var t = Emotion.getSelection();
                    t.type && t.type.toLowerCase() === "control" && (e.preventDefault(), t.clear());
                    break;
                case 13:
                    e.preventDefault(),
                            Emotion.insertHTML("<br/>");
                    Emotion.saveRange();
            }
        }).bind("mouseup", function (e) {
            Emotion.saveRange();
            if ($.browser.msie && />$/.test($contentDiv.html())) {
                var n = Emotion.getSelection();
                n.extend && (n.extend(cursorNode, cursorNode.length), n.collapseToEnd()),
                        Emotion.saveRange();
                //Emotion.insertHTML(" ");//加上此句在ie中选中会被删除
            }
        });
        $textarea.bind("contentValueChange", function () {
            $(this).val(Emotion.replaceInput($contentDiv.html()));
        });

        $contentDiv.html(Emotion.replaceEmoji($contentDiv.html().replace(/</gi, "&lt;").replace(/>/gi, "&gt;")));//.replace(/</gi, "&lt;").replace(/>/gi, "&gt;")

        $("#bsubmit").click(function () {
            var tc=$(".editArea div").html();
            if(tc!=''){
                $textarea.trigger("contentValueChange");
                Emotion.saveRange();
            }
            var c=$("#content").val();
            c=c.replace(/&lt;/gi, "<").replace(/&gt;/gi, ">");
            $("#content").val(c);
            if ($.trim($("#content").val()).length == 0) {
                G.ui.tips.info("内容不能为空");
                return;
            }
            //alert($("#content").val());
            //return false;
        });

    });
</script>
</html>
